﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZP.Common;
using ZP.DTO.Common;
using ZP.DTO.fz_base_param;
using ZP.IBLL;

namespace ZCSBZPJ.Controllers
{
    public class FZParamController : BaseController
    {

        //public FZParamController(Ifz_base_paramService _fz_base_paramService)
        //{
        //    this._fz_base_paramService = _fz_base_paramService;
        //}

        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 获得所有参数信息
        /// </summary>
        /// <returns></returns>
        public JsonResult GetAllBaseParam(string type = "")
        {
            fz_base_paramSearchDTO dto = new fz_base_paramSearchDTO { type = type };
            PageModel<fz_base_paramResultDTO> pageList = _fz_base_paramService.GetBaseParam(dto, false);
            return Json(pageList, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 参数信息-分页模糊查询
        /// </summary>
        /// <returns></returns>
        public JsonResult GetBaseParam(fz_base_paramSearchDTO dto)
        {
            PageModel<fz_base_paramResultDTO> pageList = _fz_base_paramService.GetBaseParam(dto);
            return Json(pageList, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 新增和修改-参数信息
        /// </summary>
        /// <returns></returns>
        public JsonResult SaveBaseParam(fz_base_paramOperateDTO dto)
        {
            ResultData<string> result = new ResultData<string>();
            try
            {
                UserLoginDTO loginUser = (UserLoginDTO)Session[ZPCommon.SESSION_Login];
                dto.creater = loginUser.account;
                result.SubmitResult = _fz_base_paramService.SaveBaseParam(dto);
            }
            catch (Exception e)
            {
                result.SubmitResult = false;
                result.Message = e.Message;
            }
            return Json(result);
        }

        /// <summary>
        /// 删除参数信息
        /// </summary>
        /// <returns></returns>
        public JsonResult DeleteBaseParam(List<fz_base_paramOperateDTO> dto)
        {
            ResultData<string> result = new ResultData<string>();
            try
            {
                UserLoginDTO loginUser = (UserLoginDTO)Session[ZPCommon.SESSION_Login];
                result.SubmitResult = _fz_base_paramService.DeleteBaseParam(dto, loginUser);
            }
            catch (Exception ex)
            {
                result.SubmitResult = false;
                result.Message = ex.Message;
            }
            return Json(result);

        }
    }
}